package com.itheima.zixi2.ZuoYe3;

import java.math.BigDecimal;
import java.util.Scanner;

public class Silvercard extends IdCard{
    public Silvercard() {
    }

    public Silvercard(String ID, String name, int phonenumber, double money) {
        super(ID, name, phonenumber, money);
    }

    public static void paymoney(IdCard c){
        System.out.println("请输入待支付金额：");
        Scanner sc = new Scanner(System.in);
        Double PM = sc.nextDouble();
        if(Double.compare(PM,c.getMoney())>0){
            System.out.println("您的余额不足，请充值！");
        }else{
            System.out.println("支付成功~");
            BigDecimal C = BigDecimal.valueOf(c.getMoney());
            BigDecimal pm = BigDecimal.valueOf(PM);
            BigDecimal youhui = BigDecimal.valueOf(0.9);
            BigDecimal res = C.subtract(pm.multiply(youhui));
            double res1 = res.doubleValue();
            c.setMoney(res1);
            System.out.println("您的卡内余额为："+c.getMoney());
        }
    }
}
